package wh.GameObjectFactory;
import wh.FishingPhilosopher.FishingPhilosopherActivity;
import wh.FishingPhilosopher.Components.ComponentList;
import wh.FishingPhilosopher.Components.ExternLoadAutoMoveComponent;
import wh.FishingPhilosopher.Components.FishGetTypeComponent;
import wh.FishingPhilosopher.Components.GivenGoldComponent;
import wh.FishingPhilosopher.Components.RandomAutoMoveComponent;
import wh.FishingPhilosopher.Components.RandomRemoveJudgeComponent;
import wh.FishingPhilosopher.Components.TimeCounterAutoRemovedComponent;
import wh.FishingPhilosopher.GameParams.FishParamsList;
import wh.FishingPhilosopher.GameParams.GameParams;
import wh.GameObject.FishingPhilosopherGameObject;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.RectF;

public class FishFactory {
	
	public static FishingPhilosopherGameObject createFish(Context context, PointF pointf,  float fishAngle, int fishType, RectF activeArea) {
		ComponentList componentListOfFish=new ComponentList();
		FishParamsList fishParamsList = FishParamsList.getFishParamsListByTpye(fishType);
		componentListOfFish.autoMoveComponent=new RandomAutoMoveComponent(fishParamsList.fishSpeed, activeArea);
		componentListOfFish.hasGoldComponent=new GivenGoldComponent(fishParamsList.fishGold);
		componentListOfFish.removeJudgeComponent=new RandomRemoveJudgeComponent(fishParamsList.fishProbability);
		componentListOfFish.getTypeComponent=new FishGetTypeComponent(fishType);
		FishingPhilosopherGameObject fish=new FishingPhilosopherGameObject(context, 
				pointf, 
				fishParamsList.fishResourceIdList,
				fishAngle,
				true,
				fishParamsList.fishWidth, 
				fishParamsList.fishHeight, 
				((FishingPhilosopherActivity)context).getGameParams().fishFrameRefleshInterval);
		
		fish.setComponentList(componentListOfFish);
		return fish;
	}
	
	public static FishingPhilosopherGameObject createCaughtFish(Context context, PointF pointf, float fishAngle, int fishType)
	{
		ComponentList componentListOfCaughtFish=new ComponentList();
		FishParamsList fishParamsList = FishParamsList.getFishParamsListByTpye(fishType);
		componentListOfCaughtFish.autoRemovedComponent=new TimeCounterAutoRemovedComponent(GameParams.MAX_FISH_SHOWING_TIME);
		FishingPhilosopherGameObject fish=new FishingPhilosopherGameObject(context, 
				pointf, 
				fishParamsList.fishResourceCaughtList,
				fishAngle,
				false,
				fishParamsList.fishWidth, 
				fishParamsList.fishHeight, 
				((FishingPhilosopherActivity)context).getGameParams().fishFrameRefleshInterval);
		
		fish.setComponentList(componentListOfCaughtFish);
		return fish;
	}
	
	public static FishingPhilosopherGameObject createStoryFish(Context context, PointF pointf,  float fishAngle, int fishType, RectF activeArea) {
		ComponentList componentListOfFish=new ComponentList();
		FishParamsList fishParamsList = FishParamsList.getFishParamsListByTpye(fishType);
		componentListOfFish.autoMoveComponent=new ExternLoadAutoMoveComponent(context, fishParamsList.fishSpeed);
		componentListOfFish.hasGoldComponent=new GivenGoldComponent(fishParamsList.fishGold);
		componentListOfFish.removeJudgeComponent=new RandomRemoveJudgeComponent(fishParamsList.fishProbability);
		componentListOfFish.getTypeComponent=new FishGetTypeComponent(fishType);
		FishingPhilosopherGameObject fish=new FishingPhilosopherGameObject(context, 
				pointf, 
				fishParamsList.fishResourceIdList,
				fishAngle,
				true,
				fishParamsList.fishWidth, 
				fishParamsList.fishHeight, 
				((FishingPhilosopherActivity)context).getGameParams().fishFrameRefleshInterval);
		
		fish.setComponentList(componentListOfFish);
		return fish;
	}
}
